package com.woniu108.valueAdded.controller;


import cn.hutool.core.bean.BeanUtil;
import com.woniu108.carService.commos.model.Result;
import com.woniu108.valueAdded.form.AddScoreBuyLogForm;
import com.woniu108.valueAdded.model.SocreBuyLog;
import com.woniu108.valueAdded.param.AddScoreBuyLogParam;
import com.woniu108.valueAdded.service.SocreBuyLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.time.LocalDateTime;

/**
 * <p>
 * 积分兑换记录表 前端控制器
 * </p>
 *
 * @author yanxi
 * @since 2024-05-23
 */
@RestController
@RequestMapping("/socreBuyLog")
@Api(tags = "积分兑换记录信息接口")
public class SocreBuyLogController {

    @Resource
    private SocreBuyLogService scoreBuyLogService;

    /**
     * 添加积分兑换商品记录
     * @param form 积分商品兑换记录信息
     * @return result 是否正常访问接口结果
     */
    @PostMapping("/addScoreBuyLog.api")
    @ApiOperation("添加积分兑换商品记录")
    public Result addScoreBuyLog(@RequestBody AddScoreBuyLogForm form){
            AddScoreBuyLogParam param= BeanUtil.toBean(form,AddScoreBuyLogParam.class);
            SocreBuyLog buyLog = BeanUtil.toBean(param, SocreBuyLog.class);
            buyLog.setCreateTime(LocalDateTime.now());
            scoreBuyLogService.save(buyLog);
            return Result.getResult();
    }



}

